package com.guigu.buy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.buy.pojo.ProductImage;
import com.guigu.buy.service.IProductImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author com.guigu
 * @since 2024-05-15
 */
@CrossOrigin
@Controller
@RequestMapping("/buy/productImage")
public class ProductImageController {
    @Autowired
    private IProductImageService imageService;
    //查询所有图片
    @RequestMapping("/list")
    @ResponseBody
    public List<ProductImage> list(){
        return imageService.list();
    }
    //通过商品id查询图片详情
    @RequestMapping("/imgsDetail/{id}")
    @ResponseBody
    public List<ProductImage> imgsDetail(@PathVariable int id){
        QueryWrapper<ProductImage> wrapper=new QueryWrapper<>();
         wrapper.eq("product_id",id);
        List<ProductImage> list=imageService.list(wrapper);
        return list;
    }
}
